package greed;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/*

首先介绍下0-1背包问题。假设一共有N件物品，第 i 件物品的价值为 Vi ，重量为Wi
一个小偷有一个最多只能装下重量为W的背包，他希望带走的物品越有价值越好，请问：他应该选择哪些物品？
而对于部分背包问题，不同的是他可以取走一件物品的一部分，而不一定得整件带走
那么我们只需要把单位重量价值最高的物品装入背包即可

5
100
20 30 66 40 60
10 20 30 40 50

164.0


 */
public class PartialKnapsack {
    
    static InOut0 io = new InOut0();
    int n;
    float maxWeight;
    float[] value;
    float[] weight;
    float[] rate;
    float valueSum;
    public PartialKnapsack() {
        n = io.nextInt();
        float maxWeight = io.nextFloat();
        value = new float[n];
        weight = new float[n];
        rate = new float[n];
        for (int i = 0; i < n; i++) {
            value[i] = io.nextFloat();
        }
        for (int i = 0; i < n; i++) {
            weight[i] = io.nextFloat();
            rate[i] = value[i] / weight[i];
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                if (rate[i] < rate[i+1]) {
                    float temp1 = rate[i];
                    rate[i] = rate[i+1];
                    rate[i+1] = temp1;
                    float temp2 = weight[i];
                    weight[i] = weight[i+1];
                    weight[i+1] = temp2;
                    float temp3 = value[i];
                    value[i] = value[i+1];
                    value[i+1] = temp3;
                }
            }
        }
        float tempWeight = 0;
        valueSum = 0;
        for (int i = 0; tempWeight < maxWeight; i++) {
            float temp = tempWeight + weight[i];
            if (temp <= maxWeight) {
                valueSum += value[i];
                tempWeight = temp;
            } else {
                valueSum += ((maxWeight - tempWeight) / weight[i]) * value[i];
                tempWeight = maxWeight;
            }
        }
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        PartialKnapsack p = new PartialKnapsack();
        System.out.println(p.valueSum);
    }

}
class InOut0 {
    BufferedReader br;
    StringTokenizer tok;
    PrintWriter out;
    InOut0() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
    }
    public boolean hasNext() {
        while (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                return false;
            }
        }
        return true;
    }
    
    public String next() {
        if (hasNext()) {
            return tok.nextToken();
        }
        return null;
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public float nextFloat() {
        return Float.parseFloat(next());
    }
}
